package cn.cyh.imeans.utils;

import java.util.Map;

public final class FieldUtil {
    private FieldUtil(){}


    /**
     * 将source中的非空字段，填入target
     * @param source
     * @param target
     * @return
     */
    public static Map<String, String> fillMap(Map<String, String> source, Map<String, String> target) {
        if(target == null || target.size() == 0) {
            return source;
        }
        if(source != null && source.size() > 0) {
            for (Map.Entry<String, String> entry : source.entrySet()) {
                String value = target.get(entry.getKey());
                if (value == null || value.length() == 0) {
                    target.put(entry.getKey(), entry.getValue());
                }
            }
        }
        return target;
    }
}
